#include "SteeringBehaviors.h"

Vector3D SteeringBehaviors::Vec3DNormalize(Vector3D myVector)
{
	Vector3D normalVec(myVector.getX() / myVector.getMagnitude(), 
						myVector.getY() / myVector.getMagnitude(), 
						myVector.getZ() / myVector.getMagnitude());

	return normalVec;
}

Vector3D SteeringBehaviors::Seek(Vector3D TargetPos)
{
	//desired velocity is first normalized to find the heading of where it needs to go
	//then multiplied by it's maximum velocity so it goes the right speed
	Vector3D DesiredVelocity = Vec3DNormalize(TargetPos - vpOwnedVehicle->getPos())
		* vpOwnedVehicle->getMaxSpeed();

	return (DesiredVelocity - vpOwnedVehicle->getVelocity());

}